package com.atguigu.MyTest;

import java.sql.SQLException;
import java.util.List;

/**
 * @author haoranlu
 * @project IntelliJ IDEA
 */
public class OrderDAOImp1 extends BasicDAO<Orders> implements OrderDAO{
    @Override
    public void SaveOrder(Orders order) {
    String sql = "insert into orders values(?,?,?,?,?,?)";
        try {
            update(sql,order.getId(),order.getOrderTime(),order.getTotalCount(),order.getTotalAmount(),order.getState(),order.getUserId());
        } catch (SQLException e) {
            throw new RuntimeException();
        }

    }

    @Override
    public List<Orders> getMyOrders(int userId) {
        String sql = "select * from orders where userId=?";
        List<Orders> list = getBeanList(sql, userId);
        return list;
    }
}
